﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Configuration;

namespace DAL.Persistencia
{
    public class Conexao
    {

        #region Construtores

        public Conexao()
        {

        }

        public Conexao(String senha)
        {
            ValidaConexao(senha);
        }

        private static void ValidaConexao(String senha)
        {
            try
            {
                var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                var connectionStringsSection = (ConnectionStringsSection)config.GetSection("connectionStrings");
                //connectionStringsSection.ConnectionStrings["AcessoProducao"].ConnectionString = "Data Source=EXAPRDS;User ID=emergencia;Password=" + senha + ";Unicode=True";
                connectionStringsSection.ConnectionStrings["AcessoProducao"].ConnectionString = "Data Source=SIA_CONNECT;User ID=emergencia;Password=td;Unicode=True";
                config.Save();
                ConfigurationManager.RefreshSection("connectionStrings");
            }
            catch
            {

                throw;
            }
        }
        #endregion



    }
}
